<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<title>合作媒体</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
#@css?("front")
<link rel="stylesheet" type="text/css" href="#(ctx)/front/css/main.css" />
</head>

<body>
	#@header?()
	<div class="page-banner" style="width: 100%; height: auto;">
		<img src="#(ctx)/front/img/banner-news.png" class="banner" />
	</div>
	<div class="layui-container" style="margin-top: 30px;">
		<a href="javascript:;">合作媒体</a> </span>
		<div class="main-search">
			<form class="layui-form layui-form-pane" action="#"
				onsubmit="return false;" id="queryForm">
				<div class="layui-form-item">
					<label class="layui-form-label">行业分类</label>
					<div class="layui-input-block">
						#for(ot:outtypeList) <input type="checkbox" name="outtype"
							lay-skin="primary" title="#(ot.type)" lay-filter="outtype"
							value="#(ot.id)"> #end
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">地区分类</label>
					<div class="layui-input-block">
						#for(pro:provinceList) <input type="checkbox" name="province"
							lay-skin="primary" title="#(pro.province)" lay-filter="province"
							value="#(pro.id)"> #end
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">收录类型</label>
					<div class="layui-input-block">
						<input type="radio" name="intype" lay-skin="primary" title="新闻收录"
							lay-filter="intype" value="1"> <input type="radio"
							name="intype" lay-filter="intype" lay-skin="primary" title="网页收录"
							value="0">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">其他分类</label>
					<div class="layui-input-block">
						<input type="radio" name="other" lay-skin="primary" title="周末发稿"
							lay-filter="other" value="1"> <input type="radio"
							name="other" lay-filter="other" lay-skin="primary" title="可发微商"
							value="2"> <input lay-filter="other" type="radio"
							name="other" lay-skin="primary" title="可发医疗" id="other" value="3">
						<input type="radio" name="other" lay-filter="other"
							lay-skin="primary" title="可发加盟" id="other" value="4">
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">输入条件</label>
						<div class="layui-input-inline">
							<input type="text" name="queryKey" autocomplete="off"
								id="queryKey" class="layui-input" placeholder="输入媒体名、网址"
								style="width: 400px;">
						</div>
					</div>
					<div class="layui-inline" style="margin-left: 30px;">
						<label class="layui-form-label">价格</label>
						<div class="layui-input-inline" style="width: 100px;">
							<input type="text" name="price_min" placeholder="￥"
								autocomplete="off" class="layui-input" id="min">
						</div>
						<div class="layui-form-mid">-</div>
						<div class="layui-input-inline" style="width: 100px;">
							<input type="text" name="price_max" placeholder="￥"
								autocomplete="off" class="layui-input" id="max">
						</div>
					</div>
					<div class="layui-inline">
						<button class="layui-btn" id="query" data-type="reload">查询</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						<button class="layui-btn" id="download" data-type="download">保存结果</button>
					</div>
				</div>
			</form>
		</div>
		<div class="data-view">
			<table class="layui-hide" id="dataTable"></table>
		</div>
	</div>
	#@footer?() #@js?("layui")
	<script type="text/html" id="siteTpl">
 		 <a href="{{d.site}}" class="layui-table-link" target="_blank">案例</a>
	</script>
	<script>
		//注意：导航 依赖 element 模块，否则无法进行功能性操作
		layui
				.use(
						[ 'form', 'element', 'table' ],
						function() {
							var element = layui.element, form = layui.form, table = layui.table, $ = layui.jquery;
							var province = new Map(), outtype = new Map(),other="0",intype="2";
							form.on('checkbox(outtype)', function(data) {
								if (this.checked) {
									outtype.set("ot"+data.value,data.value);
								}else{
									outtype.delete("ot"+data.value);
								}
								$('#query').click();
							});
							form.on('checkbox(province)', function(data) {
								if (this.checked) {
									province.set('pro'+data.value,data.value);
								}else{
									province.delete('pro'+data.value);
								}
								$('#query').click();
							});
							form.on('radio(other)', function(data) {
								other=data.value;
								$('#query').click();
							});
							form.on('radio(intype)', function(data) {
								intype=data.value;
								$('#query').click();
							});

							$('#query').on('click', function() {
								var type = $(this).data('type');
								active[type] ? active[type].call(this) : '';
							});
							$('#download').on('click', function() {
								var type = $(this).data('type');
								active[type] ? active[type].call(this) : '';
							});

							var active = {
								reload : function() {
									var demoReload = $('#dataTable');
									var ot= "",pro="";
									outtype.forEach(function (item) {
										ot += item +",";
									});
									province.forEach(function (item) {
										pro += item +",";
									});
									//执行重载
									table.reload('dataTable', {
										page : {
											curr : 1
										//重新从第 1 页开始
										},
										where : {
											outtype : ot,
											intype:intype,
											province : pro,
											newsname : encodeURI(encodeURI($('#queryKey').val())),
											max : $('#max').val(),
											min : $('#min').val(),
											other:other
										}
									});
								},
								download : function() {
									var demoReload = $('#dataTable');
									var ot= "",pro="";
									outtype.forEach(function (item) {
										ot += item +",";
									});
									province.forEach(function (item) {
										pro += item +",";
									});
									var queryKey = $('#queryKey').val();
									var max = $('#max').val();
									var min = $('#min').val();
									window.open("#(ctx)/file/download?t="+ot+"&p="+pro+"&n="+encodeURI(encodeURI(queryKey))+"&max="+max+"&min="+min+"&intype="+intype+"&other="+other);
								}
							};

							table.render({
								elem : '#dataTable',
								url : '#(ctx)/newslist',
								id : 'dataTable',
								page : true,
								limit: 20,
								page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
								      first: '首页' //不显示首页
								      ,last: '尾页' //不显示尾页
								      ,prev: '上一页'
								      ,next: '下一页'
								    },
								cols : [ [ {
									field : 'id',
									title : '编号',
									width : 80,
									sort : true
								}, {
									field : 'newsname',
									title : '媒体名称'
								} //width 支持：数字、百分比和不填写。你还可以通过 minWidth 参数局部定义当前单元格的最小宽度，layui 2.2.1 新增
								, {
									field : 'site',
									title : '案例',
									width : 60,
									templet: '#siteTpl'
								}, {
									field : 'province',
									title : '区域'
								}, {
									field : 'vipprice',
									title : '会员价'
								}, {
									field : 'type',
									title : '发布类型'
								},{
									field : 'intype',
									title : '收录类型',
									templet:'#intype'
								}, {
									field : 'remark',
									title : '备注',
									width : 400,
									align : 'center'
								} ] ]
							});
						});
	</script>
	<script id="intype">
		#[[
			{{#if(d.intype==1){return '新闻收录'; }}
			{{#}else {return '网页收录'; }}
			{{#} }}
		]]#
	</script>
</body>

</html>